home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Quadrant scroll fade.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  84 lines

  1. /**********************************************************************\
  2.  
  3. File:        Quadrant scroll fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 3
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30. #define NUM_ITERATIONS    25
  31.  
  32. pascal short QuadrantScrollFade(Rect boundsRect, Pattern *thePattern);
  33.  
  34. /* 4 regions, splitting the screen into 4 quadrants.  Scroll the screen right in
  35.    the top-left quadrant, down in the top-right, left in the bottom-right,
  36.    up in the bottom-left. */
  37.    
  38. pascal short QuadrantScrollFade(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     int            x;
  41.     Rect        tldest, trdest, bldest, brdest;
  42.     Rect        tlscroll, trscroll, blscroll, brscroll;
  43.     int            cx,cy;
  44.     int            BoxSize, HBoxSize;
  45.     
  46.     BoxSize=theWindowHeight/(NUM_ITERATIONS*2);
  47.     HBoxSize=theWindowWidth/(NUM_ITERATIONS*2);
  48.     
  49.     cx = boundsRect.left + theWindowWidth / 2;
  50.     cy = boundsRect.top + theWindowHeight / 2;
  51.     
  52.     tlscroll=trscroll=blscroll=brscroll=tldest=trdest=bldest=brdest=boundsRect;
  53.     tlscroll.right=trscroll.left=blscroll.right=brscroll.left=
  54.         tldest.right=trdest.left=bldest.right=brdest.left=cx;
  55.     tlscroll.bottom=trscroll.bottom=blscroll.top=brscroll.top=
  56.         tldest.bottom=trdest.bottom=bldest.top=brdest.top=cy;
  57.     tldest.right=tldest.left+HBoxSize;
  58.     trdest.bottom=trdest.top+BoxSize;
  59.     brdest.left=brdest.right-HBoxSize;
  60.     bldest.top=bldest.bottom-BoxSize;
  61.     
  62.     for (x=0; x<NUM_ITERATIONS; x++)
  63.     {
  64.         StartTiming();
  65.         ScrollTheRect(&tlscroll, HBoxSize, 0, 0L);
  66.         FillRect(&tldest, *thePattern);
  67.         
  68.         ScrollTheRect(&trscroll, 0, BoxSize, 0L);
  69.         FillRect(&trdest, *thePattern);
  70.         
  71.         ScrollTheRect(&brscroll, -HBoxSize, 0, 0L);
  72.         FillRect(&brdest, *thePattern);
  73.         
  74.         ScrollTheRect(&blscroll, 0, -BoxSize, 0L);
  75.         FillRect(&bldest, *thePattern);
  76.         
  77.         TimeCorrection(CorrectTime);
  78.     }
  79.     
  80.     FillRect(&boundsRect, *thePattern);            /* fill the whole screen to end it */
  81.     
  82.     return 0;
  83. }
  84.